<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Shell script</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Shell_script"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Shell_script rootpage-Shell_script skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Shell script</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">This article is about scripting in Unix-like systems. For batch programming in DOS, OS/2 and Windows, see <a href="Batch_file" title="Batch file">Batch file</a>. For batch programming in Windows PowerShell shell, see <a href="Windows_PowerShell" class="mw-redirect" title="Windows PowerShell">Windows PowerShell § Scripting</a>. For programming in the shells (cmd.exe) in operating systems of the Windows NT/2000 series, see <a href="Cmd.exe" title="Cmd.exe">cmd.exe</a>. For shell programming, by means of files called Command Scripts or Procedures on Vax/VMS machines, see <a href="DIGITAL_Command_Language" title="DIGITAL Command Language">DIGITAL Command Language</a>.</div>
<p>A <b>shell script</b> is a <a href="Computer_program" title="Computer program">computer program</a> designed to be run by a <a href="Unix_shell" title="Unix shell">Unix shell</a>, a <a href="Command-line_interpreter" class="mw-redirect" title="Command-line interpreter">command-line interpreter</a>.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> The various dialects of shell scripts are considered to be <a href="Command_language" title="Command language">command languages</a>. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script which sets up the environment, runs the program, and does any necessary cleanup or logging, is called a <b>wrapper</b>.
</p><p>The term is also used more generally to mean the automated mode of running an operating system shell; each operating system uses a particular name for these functions including batch files (MSDos-Win95 stream, <a href="OS/2" title="OS/2">OS/2</a>), command procedures (VMS), and shell scripts (<a href="Windows_NT" title="Windows NT">Windows NT</a> stream and third-party derivatives like <a href="4NT_(shell)" class="mw-redirect" title="4NT (shell)">4NT</a>—article is at <a href="Cmd.exe" title="Cmd.exe">cmd.exe</a>), and mainframe operating systems are associated with a number of terms.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p><p>Shells commonly present in Unix and Unix-like systems include the <a href="Korn_shell" class="mw-redirect" title="Korn shell">Korn shell</a>, the <a href="Bourne_shell" title="Bourne shell">Bourne shell</a>, and <a href="GNU_Bash" class="mw-redirect" title="GNU Bash">GNU Bash</a>. While a Unix operating system may have a different default shell, such as <a href="Zsh" class="mw-redirect" title="Zsh">Zsh</a> on <a href="MacOS" title="MacOS">macOS</a>, these shells are typically present for backwards compatibility.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Capabilities">Capabilities</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Comments">Comments</h3></div>
<p><a href="Comment_(computer_programming)" title="Comment (computer programming)">Comments</a> are ignored by the shell. They typically begin with the hash symbol (<code>#</code>), and continue until the end of the line.<sup id="cite_ref-Pro_Bash_Programming_4-0" class="reference"><a href="#cite_note-Pro_Bash_Programming-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Configurable_choice_of_scripting_language">Configurable choice of scripting language</h3></div>
<p>The <a href="Shebang_(Unix)" title="Shebang (Unix)">shebang</a>, or hash-bang, is a special kind of comment which the system uses to determine what interpreter to use to execute the file. The shebang must be the first line of the file, and start with "<code>#!</code>".<sup id="cite_ref-Pro_Bash_Programming_4-1" class="reference"><a href="#cite_note-Pro_Bash_Programming-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> In Unix-like operating systems, the characters following the "<code>#!</code>" prefix are interpreted as a path to an executable program that will interpret the script.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Shortcuts">Shortcuts</h3></div>
<p>A shell script can provide a convenient variation of a system command where special environment settings, command options, or post-processing apply automatically, but in a way that allows the new script to still act as a fully normal <a href="Unix_command" class="mw-redirect" title="Unix command">Unix command</a>.
</p><p>One example would be to create a version of <a href="Ls" title="Ls">ls</a>, the command to list files, giving it a shorter command name of <code>l</code>, which would be normally saved in a user's <code>bin</code> directory as <code>/home/<i>username</i>/bin/l</code>, and a default set of command options pre-supplied.
</p>
<div class="mw-highlight mw-highlight-lang-sh mw-content-ltr" dir="ltr"><pre><span class="ch">#!/bin/sh</span>
<span class="nv">LC_COLLATE</span><span class="o">=</span>C<span class="w"> </span>ls<span class="w"> </span>-FCas<span class="w"> </span><span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
</pre></div>
<p>Here, the first line uses a <a href="#Configurable_choice_of_scripting_language">shebang</a> to indicate which interpreter should execute the rest of the script, and the second line makes a listing with options for file format indicators, columns, all files (none omitted), and a size in blocks. The <code>LC_COLLATE=C</code> sets the default collation order to not fold upper and lower case together, not intermix <a href="Dotfile" class="mw-redirect" title="Dotfile">dotfiles</a> with normal filenames as a side effect of ignoring punctuation in the names (dotfiles are usually only shown if an option like <code>-a</code> is used), and the <code>"$@"</code> causes any parameters given to <code>l</code> to pass through as parameters to ls, so that all of the normal options and other <a href="Programming_language_syntax" class="mw-redirect" title="Programming language syntax">syntax</a> known to ls can still be used.
</p><p>The user could then simply use <code>l</code> for the most commonly used short listing.
</p><p>Another example of a shell script that could be used as a shortcut would be to print a list of all the files and directories within a given directory.
</p>
<div class="mw-highlight mw-highlight-lang-sh mw-content-ltr" dir="ltr"><pre><span class="ch">#!/bin/sh</span>
clear
ls<span class="w"> </span>-al
</pre></div>
<p>In this case, the shell script would start with its normal starting line of <span style="font-family:courier">#!/bin/sh</span>. Following this, the script executes the command <span style="font-family:courier">clear</span> which clears the terminal of all text before going to the next line. The following line provides the main function of the script. The <span style="font-family:courier">ls -al</span> command lists the files and directories that are in the directory from which the script is being run. The <span style="font-family:courier"><a href="Ls" title="Ls">ls</a></span> command attributes could be changed to reflect the needs of the user.
</p>
<div class="mw-heading mw-heading3"><h3 id="Batch_jobs">Batch jobs</h3></div>
<p>Shell scripts allow several commands that would be entered manually at a command-line interface to be executed automatically, and without having to wait for a user to trigger each stage of the sequence. For example, in a directory with three C source code files, rather than manually running the four commands required to build the final program from them, one could instead create a script for <a href="POSIX" title="POSIX">POSIX</a>-compliant shells, here named <code>build</code> and kept in the directory with them, which would compile them automatically:
</p>
<div class="mw-highlight mw-highlight-lang-sh mw-content-ltr" dir="ltr"><pre><span class="ch">#!/bin/sh</span>
<span class="nb">printf</span><span class="w"> </span><span class="s1">'compiling...\n'</span>
cc<span class="w"> </span>-c<span class="w"> </span>foo.c
cc<span class="w"> </span>-c<span class="w"> </span>bar.c
cc<span class="w"> </span>-c<span class="w"> </span>qux.c
cc<span class="w"> </span>-o<span class="w"> </span>myprog<span class="w"> </span>foo.o<span class="w"> </span>bar.o<span class="w"> </span>qux.o
<span class="nb">printf</span><span class="w"> </span><span class="s1">'done.\n'</span>
</pre></div>
<p>The script would allow a user to save the file being edited, pause the editor, and then just run <code>./build</code> to create the updated program, test it, and then return to the editor. Since the 1980s or so, however, scripts of this type have been replaced with utilities like <a href="Make_(software)" title="Make (software)">make</a> which are specialized for building programs.
</p>
<div class="mw-heading mw-heading3"><h3 id="Generalization">Generalization</h3></div>
<p>Simple batch jobs are not unusual for isolated tasks, but using shell loops, tests, and variables provides much more flexibility to users. A POSIX sh script to convert JPEG images to PNG images, where the image names are provided on the command-line—possibly via wildcards—instead of each being listed within the script, can be created with this file, typically saved in a file like <code>/home/<i>username</i>/bin/jpg2png</code>
</p>
<div class="mw-highlight mw-highlight-lang-sh mw-content-ltr" dir="ltr"><pre><span class="ch">#!/bin/sh</span>
<span class="k">for</span><span class="w"> </span>jpg<span class="p">;</span><span class="w"> </span><span class="k">do</span><span class="w"> </span><span class="c1"># use $jpg in place of each filename given, in turn</span>
<span class="w"> </span><span class="nv">png</span><span class="o">=</span><span class="si">${</span><span class="nv">jpg</span><span class="p">%.jpg</span><span class="si">}</span>.png<span class="w"> </span><span class="c1"># construct the PNG version of the filename by replacing .jpg with .png</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s1">'converting "%s" ...\n'</span><span class="w"> </span><span class="s2">"</span><span class="nv">$jpg</span><span class="s2">"</span><span class="w"> </span><span class="c1"># output status info to the user running the script</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span>convert<span class="w"> </span><span class="s2">"</span><span class="nv">$jpg</span><span class="s2">"</span><span class="w"> </span>jpg.to.png<span class="p">;</span><span class="w"> </span><span class="k">then</span><span class="w"> </span><span class="c1"># use convert (provided by ImageMagick) to create the PNG in a temp file</span>
<span class="w"> </span>mv<span class="w"> </span>jpg.to.png<span class="w"> </span><span class="s2">"</span><span class="nv">$png</span><span class="s2">"</span><span class="w"> </span><span class="c1"># if it worked, rename the temporary PNG image to the correct name</span>
<span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="c1"># ...otherwise complain and exit from the script</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span>><span class="p">&</span><span class="m">2</span><span class="w"> </span><span class="s1">'jpg2png: error: failed output saved in "jpg.to.png".\n'</span>
<span class="w"> </span><span class="nb">exit</span><span class="w"> </span><span class="m">1</span>
<span class="w"> </span><span class="k">fi</span><span class="w"> </span><span class="c1"># the end of the "if" test construct</span>
<span class="k">done</span><span class="w"> </span><span class="c1"># the end of the "for" loop</span>
<span class="nb">printf</span><span class="w"> </span><span class="s1">'all conversions successful\n'</span><span class="w"> </span><span class="c1"># tell the user the good news</span>
</pre></div>
<p>The <code>jpg2png</code> command can then be run on an entire directory full of JPEG images with just <code>/home/<i>username</i>/bin/jpg2png *.jpg</code>
</p>
<div class="mw-heading mw-heading3"><h3 id="Programming">Programming</h3></div>
<p>Many modern shells also supply various features usually found only in more sophisticated <a href="General-purpose_programming_language" title="General-purpose programming language">general-purpose programming languages</a>, such as control-flow constructs, variables, <a href="Comment_(computer_programming)" title="Comment (computer programming)">comments</a>, arrays, <a href="Subroutine" class="mw-redirect" title="Subroutine">subroutines</a> and so on. With these sorts of features available, it is possible to write reasonably sophisticated applications as shell scripts. However, they are still limited by the fact that most shell languages have little or no support for data typing systems, classes, threading, complex math, and other common full language features, and are also generally much slower than compiled code or interpreted languages written with speed as a performance goal.
</p><p>The standard Unix tools <a href="Sed" title="Sed">sed</a> and <a href="Awk" class="mw-redirect" title="Awk">awk</a> provide extra capabilities for shell programming; <a href="Perl" title="Perl">Perl</a> can also be embedded in shell scripts as can other scripting languages like <a href="Tcl" title="Tcl">Tcl</a>.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> Perl and Tcl come with graphics toolkits as well.
</p>
<div class="mw-heading mw-heading2"><h2 id="Typical_POSIX_scripting_languages">Typical POSIX scripting languages</h2></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Unix_shell" title="Unix shell">Unix shell</a></div>
<p>Scripting languages commonly found on UNIX, Linux, and POSIX-compliant operating system installations include:
</p>
<ul><li><a href="KornShell" title="KornShell">KornShell</a> (<code>ksh</code>) in several possible versions such as ksh88, Korn Shell '93 and others.</li>
<li>The <a href="Bourne_shell" title="Bourne shell">Bourne shell</a> (<code>sh</code>), one of the oldest shells still common in use</li>
<li>The <a href="C_shell" title="C shell">C shell</a> (<code>csh</code>)</li>
<li><a href="Bash_(Unix_shell)" title="Bash (Unix shell)">GNU Bash</a> (<code>bash</code>)</li>
<li><code><a href="Tclsh" class="mw-redirect" title="Tclsh">tclsh</a></code>, a shell which is a main component of the <a href="Tcl/Tk" class="mw-redirect" title="Tcl/Tk">Tcl/Tk</a> programming language.</li>
<li>The <a href="Wish_(shell)" class="mw-redirect" title="Wish (shell)">wish</a> is a GUI-based Tcl/Tk shell.</li></ul>
<p>The C and Tcl shells have syntax quite similar to that of said programming languages, and the Korn shells and Bash are developments of the Bourne shell, which is based on the <a href="ALGOL" title="ALGOL">ALGOL</a> language with elements of a number of others added as well.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> On the other hand, the various shells plus tools like <a href="Awk" class="mw-redirect" title="Awk">awk</a>, <a href="Sed" title="Sed">sed</a>, <a href="Grep" title="Grep">grep</a>, and <a href="BASIC" title="BASIC">BASIC</a>, <a href="Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a>, <a href="C_(programming_language)" title="C (programming language)">C</a> and so forth contributed to the <a href="Perl" title="Perl">Perl</a> programming language.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p><p>Other shells that may be available on a machine or for download and/or purchase include:
</p>
<ul><li><a href="Almquist_shell" title="Almquist shell">Almquist shell</a> (<code>ash</code>)</li>
<li>Nushell (<code>nu</code>)</li>
<li><a href="PowerShell" title="PowerShell">PowerShell</a> (<code>msh</code>)</li>
<li><a href="Z_shell" title="Z shell">Z shell</a> (<code>zsh</code>, a particularly common enhanced KornShell)</li>
<li>The <a href="Tenex_C_Shell" class="mw-redirect" title="Tenex C Shell">Tenex C Shell</a> (<code>tcsh</code>).</li></ul>
<p>Related programs such as shells based on <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a>, <a href="C_(programming_language)" title="C (programming language)">C</a>, <a href="Java_(programming_language)" title="Java (programming language)">Java</a>, <a href="Perl" title="Perl">Perl</a>, <a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>, <a href="Rexx" title="Rexx">Rexx</a> etc. in various forms are also widely available. Another somewhat common shell is Old shell (<code>osh</code>), whose manual page states it "is an enhanced, backward-compatible port of the standard command interpreter from Sixth Edition UNIX."<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p><p>So called remote shells such as
</p>
<ul><li>a <a href="Remote_Shell" title="Remote Shell">Remote Shell</a> (<code>rsh</code>)</li>
<li>a <a href="Secure_Shell" title="Secure Shell">Secure Shell</a> (<code>ssh</code>)</li></ul>
<p>are really just tools to run a more complex shell on a remote system and have no 'shell' like characteristics themselves.
</p>
<div class="mw-heading mw-heading2"><h2 id="Other_scripting_languages">Other scripting languages</h2></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Scripting_language" title="Scripting language">Scripting language</a></div>
<p>Many powerful scripting languages, such as Python, Perl, and Tcl, have been introduced to address tasks that are too large, complex, or repetitive to be comfortably handled by traditional shell scripts, while avoiding the overhead associated with compiled languages like C or Java.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</p><p>Although the distinction between scripting languages and general-purpose high-level programming languages is often debated, scripting languages are typically characterized by their interpreted nature, simplified syntax, and primary use in automating tasks, coordinating system operations, and writing "glue code" between components.<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> Even when scripting languages such as Python or JavaScript support compilation to bytecode or use <a href="Just-in-time_compilation" title="Just-in-time compilation">JIT</a> to improve performance, they are still commonly referred to as "scripting languages" due to their historical association with automation, lightweight tooling, and scripting environments rather than standalone application development.
</p><p>Importantly, scripting is a form of programming. While "scripting" may emphasize lightweight, task-oriented automation, the broader term "programming" encompasses both scripting and software development in compiled or structured languages. As such, scripting involves writing code to instruct a computer to perform specific tasks—meeting the fundamental definition of programming.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Life_cycle">Life cycle</h2></div>
<p>Shell scripts often serve as an initial stage in software development, and are often subject to conversion later to a different underlying implementation, most commonly being converted to <a href="Perl" title="Perl">Perl</a>, <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, or <a href="C_(programming_language)" title="C (programming language)">C</a>. The <a href="Interpreter_directive" class="mw-redirect" title="Interpreter directive">interpreter directive</a> allows the implementation detail to be fully hidden inside the script, rather than being exposed as a filename extension, and provides for seamless reimplementation in different languages with no impact on end users.
</p><p>While files with the ".sh" <a href="File_extension" class="mw-redirect" title="File extension">file extension</a> are usually a shell script of some kind, most shell scripts do not have any filename extension.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Advantages_and_disadvantages">Advantages and disadvantages</h2></div>
<p>Perhaps the biggest advantage of writing a shell script is that the commands and syntax are exactly the same as those directly entered at the command-line. The programmer does not have to switch to a totally different syntax, as they would if the script were written in a different language, or if a compiled language were used.
</p><p>Often, writing a shell script is much quicker than writing the equivalent code in other programming languages. The many advantages include easy program or file selection, quick start, and interactive debugging. A shell script can be used to provide a sequencing and decision-making linkage around existing programs, and for moderately sized scripts the absence of a compilation step is an advantage. Interpretive running makes it easy to write debugging code into a script and re-run it to detect and fix bugs. Non-expert users can use scripting to tailor the behavior of programs, and shell scripting provides some limited scope for multiprocessing.
</p><p>On the other hand, shell scripting is prone to costly errors. Inadvertent typing errors such as <code><a href="Rm_(Unix)" title="Rm (Unix)">rm</a> -rf * /</code> (instead of the intended <code>rm -rf */</code>) are folklore in the Unix community; a single extra space converts the command from one that deletes all subdirectories contained in the current directory, to one which deletes everything from the file system's <a href="Root_directory" title="Root directory">root directory</a>.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup> Similar problems can transform <code><a href="Cp_(Unix)" title="Cp (Unix)">cp</a></code> and <code><a href="Mv_(Unix)" title="Mv (Unix)">mv</a></code> into dangerous weapons, and misuse of the <code>></code> redirect can delete the contents of a file.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p><p>Another significant disadvantage is the slow execution speed and the need to launch a new process for almost every shell command executed. When a script's job can be accomplished by setting up a <a href="Pipeline_(computing)" title="Pipeline (computing)">pipeline</a> in which efficient <a href="Filter_(software)" title="Filter (software)">filter</a> commands perform most of the work, the slowdown is mitigated, but a complex script is typically several orders of magnitude slower than a conventional compiled program that performs an equivalent task.
</p><p>There are also compatibility problems between different platforms. <a href="Larry_Wall" title="Larry Wall">Larry Wall</a>, creator of <a href="Perl" title="Perl">Perl</a>, famously wrote that "It's easier to port a shell than a shell script."<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup>
</p><p><br>
</p><p><br>
Similarly, more complex scripts can run into the limitations of the shell scripting language itself; the limits make it difficult to write quality code, and extensions by various shells to ameliorate problems with the original shell language can make problems worse.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</p><p>Many disadvantages of using some script languages are caused by design flaws within the <a href="Programming_language_syntax" class="mw-redirect" title="Programming language syntax">language syntax</a> or implementation, and are not necessarily imposed by the use of a text-based command-line; there are a number of shells which use other shell programming languages or even full-fledged languages like <a href="Scsh" title="Scsh">Scsh</a> (which uses <a href="Scheme_(programming_language)" title="Scheme (programming language)">Scheme</a>).
</p>
<div class="mw-heading mw-heading2"><h2 id="Interoperability_among_scripting_languages">Interoperability among scripting languages</h2></div>
<p>Many scripting languages share similar syntax and features due to their adherence to the <a href="POSIX" title="POSIX">POSIX</a> standard, and several shells provide modes to emulate or maintain compatibility with others. This allows scripts written for one shell to often run in another with minimal changes.
</p><p>For example, <a href="Bash_(Unix_shell)" title="Bash (Unix shell)">Bash</a> supports much of the original <a href="Bourne_shell" title="Bourne shell">Bourne shell</a> syntax and offers a POSIX-compliant mode to improve portability. However, Bash also includes a number of extensions not found in POSIX, commonly referred to as <a href="Bash_(Unix_shell)#Portability_with_POSIX" title="Bash (Unix shell)">bashisms</a>. While these features enhance scripting capabilities, they may reduce compatibility with other shells like <a href="Dash_(shell)" class="mw-redirect" title="Dash (shell)">Dash</a> or <a href="KornShell" title="KornShell">ksh</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Shell_scripting_on_other_operating_systems">Shell scripting on other operating systems</h2></div>
<p>Interoperability software such as <a href="Cygwin" title="Cygwin">Cygwin</a>, the <a href="MKS_Toolkit" title="MKS Toolkit">MKS Toolkit</a>, <a href="Interix" title="Interix">Interix</a> (formerly part of Microsoft Windows Services for UNIX), <a href="Hamilton_C_shell" title="Hamilton C shell">Hamilton C shell</a>, and <a href="UWIN" title="UWIN">UWIN</a> (AT&T Unix for Windows) enables Unix shell programs to run on Windows NT-based systems, though some features may not be fully supported on the older <a href="MS-DOS" title="MS-DOS">MS-DOS</a>/<a href="Windows_95" title="Windows 95">Windows 95</a> platforms. Earlier versions of the MKS Toolkit also provided support for OS/2.
</p><p>In addition, several DCL (Digital Command Language) implementations are available for Windows environments. These include scripting tools like <a href="XLNT" title="XLNT">XLNT</a>, which integrates with the Windows command shell and supports automation for <a href="Common_Gateway_Interface" title="Common Gateway Interface">CGI</a> programming and <a href="Windows_Script_Host" title="Windows Script Host">Windows Script Host</a>. macOS (formerly Mac OS X) is also Unix-based and includes a POSIX-compliant shell environment by default.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup>
</p><p>The console alternatives <a href="4DOS" title="4DOS">4DOS</a>, <a href="4OS2" title="4OS2">4OS2</a>, <a href="FreeDOS" title="FreeDOS">FreeDOS</a>, <a href="Peter_Norton" title="Peter Norton">Peter Norton</a>'s <a href="NDOS" class="mw-redirect" title="NDOS">NDOS</a> and 4NT / Take Command which add functionality to the Windows NT-style cmd.exe, MS-DOS/Windows 95 batch files (run by Command.com), OS/2's cmd.exe, and 4NT respectively are similar to the shells that they enhance and are more integrated with the Windows Script Host, which comes with three pre-installed engines, VBScript, <a href="JScript" title="JScript">JScript</a>, and <a href="Visual_Basic_for_Applications" title="Visual Basic for Applications">VBA</a> and to which numerous third-party engines can be added, with Rexx, Perl, Python, Ruby, and Tcl having pre-defined functions in 4NT and related programs. <a href="PC_DOS" class="mw-redirect" title="PC DOS">PC DOS</a> is quite similar to MS-DOS, whilst <a href="DR_DOS" class="mw-redirect" title="DR DOS">DR DOS</a> is more different. Earlier versions of Windows NT are able to run contemporary versions of 4OS2 by the OS/2 subsystem.
</p><p>Scripting languages are, by definition, able to be extended; for example, a MS-DOS/Windows 95/98 and Windows NT type systems allows for shell/batch programs to call tools like <a href="KiXtart" title="KiXtart">KiXtart</a>, <a href="QBasic" title="QBasic">QBasic</a>, various <a href="BASIC" title="BASIC">BASIC</a>, <a href="Rexx" title="Rexx">Rexx</a>, <a href="Perl" title="Perl">Perl</a>, and <a href="Python_(programming_language)" title="Python (programming language)">Python</a> implementations, the <a href="Windows_Script_Host" title="Windows Script Host">Windows Script Host</a> and its installed engines. On Unix and other <a href="POSIX" title="POSIX">POSIX</a>-compliant systems, <a href="Awk" class="mw-redirect" title="Awk">awk</a> and <a href="Sed" title="Sed">sed</a> are used to extend the string and numeric processing ability of shell scripts. <a href="Tcl" title="Tcl">Tcl</a>, Perl, Rexx, and Python have graphics toolkits and can be used to code functions and procedures for shell scripts which pose a speed bottleneck (C, Fortran, assembly language &c are much faster still) and to add functionality not available in the shell language such as sockets and other connectivity functions, heavy-duty text processing, working with numbers if the calling script does not have those abilities, self-writing and self-modifying code, techniques like <a href="Recursion" title="Recursion">recursion</a>, direct memory access, various types of <a href="Sorting" title="Sorting">sorting</a> and more, which are difficult or impossible in the main script, and so on. <a href="Visual_Basic_for_Applications" title="Visual Basic for Applications">Visual Basic for Applications</a> and <a href="VBScript" title="VBScript">VBScript</a> can be used to control and communicate with such things as spreadsheets, databases, scriptable programs of all types, telecommunications software, development tools, graphics tools and other software which can be accessed through the <a href="Component_Object_Model" title="Component Object Model">Component Object Model</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Glue_code" title="Glue code">Glue code</a></li>
<li><a href="Interpreter_directive" class="mw-redirect" title="Interpreter directive">Interpreter directive</a></li>
<li><a href="Shebang_(Unix)" title="Shebang (Unix)">Shebang symbol (#!)</a></li>
<li><a href="Unix_shell" title="Unix shell">Unix shells</a></li>
<li><a href="PowerShell" title="PowerShell">PowerShell</a></li>
<li><a href="Windows_Script_Host" title="Windows Script Host">Windows Script Host</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFKernighanPike1984" class="citation cs2"><a href="Brian_Kernighan" title="Brian Kernighan">Kernighan, Brian W.</a>; <a href="Rob_Pike" title="Rob Pike">Pike, Rob</a> (1984), "3. Using the Shell", <i>The UNIX Programming Environment</i>, Prentice Hall, Inc., p. 94, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-13-937699-2</bdi>, <q>The shell is actually a programming language: it has variables, loops, decision-making, and so on.</q></cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.ibm.com/docs/en/zos/3.1.0?topic=introduction-job-control-language-jcl">"Job Control Language"</a>. IBM<span class="reference-accessdate">. Retrieved <span class="nowrap">2025-06-12</span></span>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFArnold_Robbins_and_Nelson_H.F._Beebe2005" class="citation book cs1">Arnold Robbins and Nelson H.F. Beebe (2005). <i>Classic Shell Scripting</i>. O'Reilly Media. p. 5. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-596-00595-5</bdi>.</cite></span>
</li>
<li id="cite_note-Pro_Bash_Programming-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-Pro_Bash_Programming_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Pro_Bash_Programming_4-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFJohnson2009" class="citation book cs1">Johnson, Chris (2009). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=NJmhi6T0nGMC&q=comment"><i>Pro Bash Programming: Scripting the Linux Shell</i></a>. Apress. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781430219989</bdi><span class="reference-accessdate">. Retrieved <span class="nowrap">September 27,</span> 2019</span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://linux.die.net/man/3/execve">"exec(3p) – POSIX Programmer's Manual"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-07-24</span></span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFStephen_G._Kochan,_Patrick_H._Wood2003" class="citation book cs1">Stephen G. Kochan, Patrick H. Wood (2003). <i>Unix Shell Programming</i>. Sams Publishing. p. 243. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9780672324901</bdi>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text">Unix Shells By Example, pp 7-10,</span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFWallChristiansenOrwant2012" class="citation book cs1">Wall, Larry; Christiansen, Tom; Orwant, Jon (2012). <i>Programming Perl</i> (5 ed.). O'Reilly Media. p. Preface. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781449303587</bdi>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://manned.org/osh/f30afb07">"osh - manned.org"</a>. <i>manned.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-01-16</span></span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite id="CITEREFFlanagan2020" class="citation book cs1">Flanagan, David (2020). <i>JavaScript: The Definitive Guide</i>. O'Reilly Media. p. 2. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781491952023</bdi>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite id="CITEREFHarold2013" class="citation book cs1">Harold, Elliotte Rusty (2013). <i>Java Network Programming</i>. O'Reilly Media. p. 6. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781449365943</bdi>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite id="CITEREFLutz2013" class="citation book cs1">Lutz, Mark (2013). <i>Learning Python</i> (5 ed.). O'Reilly Media. p. 6. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781449355739</bdi>. <q>Python is often called a scripting language, but really it's just a general-purpose programming language that's also good at scripting. In fact, scripting is just a subset of programming in general.</q></cite></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite id="CITEREFRobbinsHannahLamb2008" class="citation book cs1">Robbins, Arnold; Hannah, Elbert; Lamb, Linda (2008). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=J5nKVVg5YHAC"><i>Learning the vi and Vim Editors</i></a>. "O'Reilly Media, Inc.". p. 205. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781449313258</bdi>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite id="CITEREFEasttom2012" class="citation book cs1">Easttom, Chuck (2012). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=zZYLAAAAQBAJ"><i>Essential Linux Administration:: A Comprehensive Guide for Beginners</i></a>. Course Technology/Cengage Learning. p. 228. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1435459571</bdi>.</cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite id="CITEREFKumari2015" class="citation book cs1">Kumari, Sinny (November 23, 2015). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=9vCoCwAAQBAJ&q=shell+script+file+extension&pg=PA2"><i>Linux Shell Scripting Essentials</i></a>. Packt Publishing Ltd. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781783552375</bdi><span class="reference-accessdate">. Retrieved <span class="nowrap">May 7,</span> 2017</span>. <q>Rather than using a file extension for shell scripts, it's preferred to keep a filename without extension and let an interpreter identify the type by looking into shebang(#!).</q></cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><cite id="CITEREFTaylorPerry2016" class="citation book cs1">Taylor, Dave; Perry, Brandon (December 16, 2016). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=Mpi7DQAAQBAJ&q=shell+script+file+extension&pg=PA5"><i>Wicked Cool Shell Scripts, 2nd Edition: 101 Scripts for Linux, OS X and UNIX Systems</i></a>. No Starch Press. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781593276027</bdi><span class="reference-accessdate">. Retrieved <span class="nowrap">May 7,</span> 2017</span>. <q>Shell scripts don't need a special file extension, so leave the extension blank (or you can add the extension .sh if you prefer, but this isn't required.</q></cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite id="CITEREFShotts2019" class="citation book cs1">Shotts, William (2019). <i>The Linux Command Line</i>. No Starch Press. p. 72. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9781593279523</bdi>.</cite></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite id="CITEREFAlbingVossenNewham2007" class="citation book cs1">Albing, Carl; Vossen, JP; Newham, Cameron (2007). <i>Bash Cookbook</i>. O'Reilly Media. p. 53. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9780596526788</bdi>.</cite></span>
</li>
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><cite id="CITEREFLarry_Wall1991" class="citation newsgroup cs1"><a href="Larry_Wall" title="Larry Wall">Larry Wall</a> (January 4, 1991). <a rel="nofollow" class="external text" href="https://www.tuhs.org/Usenet/comp.unix.shell/1991-January/002464.html">"Finding the last arg"</a>. <a href="Usenet_newsgroup" title="Usenet newsgroup">Newsgroup</a>: <a rel="nofollow" class="external text" href="news:comp.unix.shell">comp.unix.shell</a><span class="reference-accessdate">. Retrieved <span class="nowrap">January 5,</span> 2023</span>.</cite></span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><cite id="CITEREFChristiansen,_Tom" class="citation web cs1">Christiansen, Tom. <a rel="nofollow" class="external text" href="https://www.ooblick.com/text/CshProgrammingConsideredHarmful.html">"Csh Programming Considered Harmful"</a>.</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.apple.com/library/archive/documentation/OpenSource/Conceptual/ShellScripting/">"MacOS and the Unix Environment"</a>. Apple Developer Documentation<span class="reference-accessdate">. Retrieved <span class="nowrap">2025-06-12</span></span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */
.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */
@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}
/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */
.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}
/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikibooks has a book on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Shell_Programming" class="extiw external" title="wikibooks:Shell Programming">Shell Programming</a></b></i></div></div>
</div>
<ul><li><a rel="nofollow" class="external text" href="http://www.faqs.org/docs/air/tsshell.html"><i>An Introduction To Shell Programming</i> by Greg Goebel</a></li>
<li><a rel="nofollow" class="external text" href="https://www.shellscript.sh"><i>UNIX / Linux shell scripting tutorial</i> by Steve Parker</a></li>
<li><a rel="nofollow" class="external text" href="https://developer.apple.com/mac/library/documentation/OpenSource/Conceptual/ShellScripting/"><i>Shell Scripting Primer</i> (Apple)</a></li>
<li><a rel="nofollow" class="external text" href="https://www.linux.com/articles/34658"><i>What to watch out for when writing portable shell scripts</i> by Peter Seebach</a></li>
<li><a rel="nofollow" class="external text" href="http://freebookcentre.net/UnixCategory/Free-Unix-Shell-Programming-Books-Download.html">Free Unix Shell scripting books</a></li>
<li><a rel="nofollow" class="external text" href="https://help.ubuntu.com/community/Beginners/BashScripting">Beginners/BashScripting</a>, Ubuntu Linux</li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Programming_languages625" style="padding:3px"><table class="nowraplinks hlist mw-collapsible expanded navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Programming_languages625" style="font-size:114%;margin:0 4em"><a href="Programming_language" title="Programming language">Programming languages</a></div></th></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><a href="Comparison_of_programming_languages" title="Comparison of programming languages">Comparison</a></li>
<li><a href="Timeline_of_programming_languages" title="Timeline of programming languages">Timeline</a></li>
<li><a href="History_of_programming_languages" title="History of programming languages">History</a></li></ul>
</div></td></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a></li>
<li><a href="ALGOL" title="ALGOL">ALGOL</a>
<ul><li><a href="Simula" title="Simula">Simula</a></li></ul></li>
<li><a href="APL_(programming_language)" title="APL (programming language)">APL</a></li>
<li><a href="Assembly_language" title="Assembly language">Assembly</a></li>
<li><a href="BASIC" title="BASIC">BASIC</a>
<ul><li><a href="Visual_Basic" title="Visual Basic">Visual Basic</a>
<ul><li><a href="Visual_Basic_(classic)" title="Visual Basic (classic)">classic</a></li>
<li><a href="Visual_Basic_(.NET)" title="Visual Basic (.NET)">.NET</a></li></ul></li></ul></li>
<li><a href="C_(programming_language)" title="C (programming language)">C</a></li>
<li><a href="C%2B%2B" title="C++">C++</a></li>
<li><a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a></li>
<li><a href="COBOL" title="COBOL">COBOL</a></li>
<li><a href="Erlang_(programming_language)" title="Erlang (programming language)">Erlang</a>
<ul><li><a href="Elixir_(programming_language)" title="Elixir (programming language)">Elixir</a></li></ul></li>
<li><a href="Forth_(programming_language)" title="Forth (programming language)">Forth</a></li>
<li><a href="Fortran" title="Fortran">Fortran</a></li>
<li><a href="Go_(programming_language)" title="Go (programming language)">Go</a></li>
<li><a href="Haskell" title="Haskell">Haskell</a></li>
<li><a href="Java_(programming_language)" title="Java (programming language)">Java</a></li>
<li><a href="JavaScript" title="JavaScript">JavaScript</a></li>
<li><a href="Julia_(programming_language)" title="Julia (programming language)">Julia</a></li>
<li><a href="Kotlin_(programming_language)" title="Kotlin (programming language)">Kotlin</a></li>
<li><a href="Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a></li>
<li><a href="Lua" title="Lua">Lua</a></li>
<li><a href="MATLAB" title="MATLAB">MATLAB</a></li>
<li><a href="ML_(programming_language)" title="ML (programming language)">ML</a>
<ul><li><a href="Caml" title="Caml">Caml </a>
<ul><li><a href="OCaml" title="OCaml">OCaml</a></li></ul></li></ul></li>
<li><a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>
<ul><li><a href="Object_Pascal" title="Object Pascal">Object Pascal</a></li></ul></li>
<li><a href="Perl" title="Perl">Perl </a>
<ul><li><a href="Raku_(programming_language)" title="Raku (programming language)">Raku</a></li></ul></li>
<li><a href="PHP" title="PHP">PHP</a></li>
<li><a href="Prolog" title="Prolog">Prolog</a></li>
<li><a href="Python_(programming_language)" title="Python (programming language)">Python</a></li>
<li><a href="R_(programming_language)" title="R (programming language)">R</a></li>
<li><a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a></li>
<li><a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a></li>
<li><a href="SAS_language" title="SAS language">SAS</a></li>
<li><a href="SQL" title="SQL">SQL</a></li>
<li><a href="Scratch_(programming_language)" title="Scratch (programming language)">Scratch</a></li>
<li><a href="Smalltalk" title="Smalltalk">Smalltalk</a></li>
<li><a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a></li>
<li><i><a href="List_of_programming_languages" title="List of programming languages">more...</a></i></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><span class="noviewer" typeof="mw:File"><span title="List-Class article"></span></span> <b>Lists:</b> <a href="List_of_programming_languages" title="List of programming languages">Alphabetical</a></li>
<li><a href="List_of_programming_languages_by_type" title="List of programming languages by type">Categorical</a></li>
<li><a href="Generational_list_of_programming_languages" title="Generational list of programming languages">Generational</a></li>
<li><a href="Non-English-based_programming_languages" title="Non-English-based programming languages">Non-English-based</a></li>
<li><span class="noviewer" typeof="mw:File"><span title="Category"></span></span> Category</li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-31" href="https://en.wikipedia.org/wiki/?title=Shell_script&oldid=1303464099">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>